
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>授权</title>


    <link rel="shortcut icon" href="favicon.ico">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="/Public/Admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min.css?v=4.1.0" rel="stylesheet">

    <style>
        .pages a,
        .pages span {
            display: inline-block;
            padding: 5px 18px;
            margin: 0 1px;
            border: 1px solid #f0f0f0;
            -webkit-border-radius: 3px;
            -moz-border-radius: 3px;
            border-radius: 3px;
            font-size: 15px;
        }

        .pages a,
        .pages li {
            display: inline-block;
            list-style: none;
            text-decoration: none;
            color: #58A0D3;
        }

        .pages a.first,
        .pages a.prev,
        .pages a.next,
        .pages a.end {
            margin: 0;
        }

        .pages a:hover {
            border-color: #50A8E6;
        }

        .pages span.current {
            background: #50A8E6;
            color: #FFF;
            font-weight: 700;
            border-color: #50A8E6;
        }
        .color{background: red;border-color: red;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>
                        <small>授权</small>
                    </h5>

                </div>
                <div class="ibox-content">
                    <input type="hidden" id="appid" name="appid" value="{$appid}">
                    <input type="hidden" id="appname" name="appname" value="{$info['appname']}">
                    <a class="btn btn-primary " href="{$url}">授权</a>
                    <a class="btn btn-primary " onclick="uploadcode()">上传代码</a>
                    <a class="btn btn-primary " onclick="getimg()">获取体验码</a>
                    <a class="btn btn-primary " onclick="submitaudt()">提交审核</a>
                    <a class="btn btn-primary " onclick="release()">点击发布</a>
                </div>

            </div>
        </div>
    </div>

</div>

<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/contabs.min.js?v=1.0"></script>
<script src="/Public/Admin/js/plugins/layer/layer.js?v=1.0"></script>
<script>
    function uploadcode() {
        var appid = $('#appid').val();
        location.href = "{:U('Auth/applog')}?appid="+appid;

    }

    function submitaudt() {
        var appid = $('#appid').val();
        var appname = $('#appname').val();
        layer.msg('提交中，请稍等', {icon: 1});
        var url = "{:U('Auth/submitaudit')}";
        $.ajax({
            type : 'post',
            url  : url+'?t='+Math.random(),
            data : 'appid='+appid+'&appname='+appname,
            dataType : 'json',
            beforeSend: function(){
                lock = 1;
                layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            },
            success : function(res){
                layer.closeAll();
                if(res.errcode == 0){
                    layer.msg('成功', {icon: 1});
                    // var t = window.setTimeout("reload()",1000);

                }else{
                    layer.msg(res.errcode, {icon: 2});
                }
            },
            complete: function(){
                lock = 0;
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                layer.closeAll();
                layer.msg('网络失败，请刷新页面后重试', {icon: 2});
            }
        })

    }

    function getimg() {
        var appid = $('#appid').val();

        layer.msg('提交中，请稍等', {icon: 1});
        var url = "{:U('Auth/getexperience')}";
        $.ajax({
            type : 'post',
            url  : url+'?t='+Math.random(),
            data : 'appid='+appid,
            dataType : 'json',
            beforeSend: function(){
                lock = 1;
                layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            },
            success : function(res){
                layer.closeAll();
                if(res.error == 0){
                    alert(res.save_path);
                    // var t = window.setTimeout("reload()",1000);

                }else{
                    layer.msg(res.errcode, {icon: 2});
                }
            },
            complete: function(){
                lock = 0;
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                layer.closeAll();
                layer.msg('网络失败，请刷新页面后重试', {icon: 2});
            }
        })



    }


    function release() {
        var appid = $('#appid').val();

        layer.msg('提交中，请稍等', {icon: 1});
        var url = "{:U('Auth/release')}";
        $.ajax({
            type : 'post',
            url  : url+'?t='+Math.random(),
            data : 'appid='+appid,
            dataType : 'json',
            beforeSend: function(){
                lock = 1;
                layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            },
            success : function(res){
                layer.closeAll();
                if(res.errcode == 0){
                    layer.msg('成功', {icon: 1});
                    // var t = window.setTimeout("reload()",1000);

                }else{
                    layer.msg(res.errcode, {icon: 2});
                }
            },
            complete: function(){
                lock = 0;
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                layer.closeAll();
                layer.msg('网络失败，请刷新页面后重试', {icon: 2});
            }
        })



    }


    function reload()
    {
        document.location.reload();//当前页面

    }


</script>

</body>

</html>
